﻿using System.Web.Mvc;
using BSU.CSCE.Data.Model;
using BSU.CSCE.Utilities;

namespace BSU.CSCE.Web.Models
{
    public abstract class PublicationFormViewModel
    {
        public PublicationFormViewModel(Publication publication)
        {
            Publication = publication;

            PublicationStatuses = new SelectList(
                EnumTranslator.Translate(typeof(PublicationStatus)),
                Reflector.GetPropertyName<EnumItem>(x => x.Value),
                Reflector.GetPropertyName<EnumItem>(x => x.Text),
                publication.Status);

            PublicationTypes = new SelectList(
                EnumTranslator.Translate(typeof(PublicationType)),
                Reflector.GetPropertyName<EnumItem>(x => x.Value),
                Reflector.GetPropertyName<EnumItem>(x => x.Text),
                publication.Type);
        }

        public Publication Publication { get; private set; }
        public SelectList PublicationStatuses { get; private set; }
        public SelectList PublicationTypes { get; private set; }
    }
}
